<?php

namespace app\common\model\Product;

use think\Model;

class ProductType extends Model
{
    //
    protected $table = 'pre_product_type';

    // 追加字段
    protected $append = [
        'cover_cdn',
    ];

    // 封面图
    public function getCoverCdnAttr($value, $data)
    {
        $cover = @is_file('.' . $data['cover']) ? '.' . $data['cover'] : '/static/home/res/images/back_1.jpg';

        $cdn = model('Config')->where(['key' => 'SiteUrl'])->value('value');

        return $cdn . $cover;
    }
}
